***Replication Data for "Resisting the Blood Tax"*******************************
***Appendix - AOF Dataset*******************************************************
***Lindsey Pruett. September 2023.**********************************************
***Stata 17.0*******************************************************************
********************************************************************************

clear
use "C:\Users\ldpru\OneDrive\Desktop\Replication_JOP\JOP_Pruett_draftevasion.dta"

*Table 1: Descriptive Statistics of DV by Colony

tabstat abs_pop, by(country)  stat(n mean sd min max)


*Table 2: Summary Statistics
global VARS abs_pop Rails_per50k log_area altitude precipitations frontmaritime distcoast ind_fleuve log_distance border_percent wwi_resist anc_royaume acephale_isole dureeresistance log_predist eligible wwi_pop Total_posts corvee_bin admin_total

eststo total: estpost summarize $VARS

esttab total total total total total using bI_sum.tex, replace ///
cell(count(pattern(1 0 0 0 0) fmt(0)) & mean(pattern(0 1 0 0 0) fmt(2)) & sd(pattern(0 0 1 0 0) fmt(2)) & min(pattern(0 0 0 1 0) fmt(0)) & max(pattern(0 0 0 0 1) fmt(2))) mtitle("n" "Mean" "SD" "Min" "Max")


*Table 3: Balance of Means All Data

eststo norail: estpost summarize $VARS if railway==0
eststo rail: estpost summarize $VARS if railway ==1
eststo diff: estpost ttest $VARS, by(railway)
eststo brail: estpost summarize $VARS if avg_rail_bb==0
eststo arail: estpost summarize $VARS if avg_rail_bb==1
eststo diff2: estpost ttest $VARS, by(avg_rail_bb)

esttab norail rail diff diff brail arail diff2 diff2 using bII_bal.tex, replace ///
cell(mean(pattern(1 1 0 0 1 1 0 0) fmt(2)) & b(pattern(0 0 1 0 0 0 1 0) fmt(2)) & p(pattern(0 0 0 1 0 0 0 1) fmt(2))) mtitle("No Rail" "Railway" "Diff." "p-value" "Below Avg" "Above Avg." "Diff." "p-value")


*Table 4: Balance of Means, Dropping "Always Treated"

eststo norail: estpost summarize $VARS if railway==0
eststo rail: estpost summarize $VARS if railway ==1 & rails_pre20==0
eststo diff: estpost ttest $VARS if rails_pre20==0, by(railway)

gen always = 0 /*indicates if the district always had above average rail density*/
replace always = 1 if avg_rail_year>=1 & avg_rail_year <=1920 

eststo brail: estpost summarize $VARS if avg_rail_bb==0 
eststo arail: estpost summarize $VARS if avg_rail_bb==1 & always == 0 
eststo diff2: estpost ttest $VARS if always==0, by(avg_rail_bb)

esttab norail rail diff diff brail arail diff2 diff2 using bII_bal2.tex, replace ///
cell(mean(pattern(1 1 0 0 1 1 0 0) fmt(2)) & b(pattern(0 0 1 0 0 0 1 0) fmt(2)) & p(pattern(0 0 0 1 0 0 0 1) fmt(2))) mtitle("No Rail" "Railway" "Diff." "p-value" "Below Avg" "Above Avg." "Diff." "p-value")

drop always

*Table 5: Predicting Missing Data in DV

gen missing_abs = 0
replace missing_abs= 1 if abs_pop ==.

logit missing_abs Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir year
outreg2 using missing.tex, tex(fragment pretty) replace	dec(2) pdec(3)

logit missing_abs Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir year if col25=="HV"
outreg2 using missing.tex, tex(fragment pretty) append	dec(2) pdec(3)

logit missing_abs Rails_per50k building_rail pcpop admin_total limit Total_posts log_predist border_percent ind_fleuve coltotal log_distance wwi_resist log_area anc_comptoir year if col25=="DAH"
outreg2 using missing.tex, tex(fragment pretty) append	dec(2) pdec(3)

logit missing_abs Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir year if col25=="CDI"
outreg2 using missing.tex, tex(fragment pretty) append	dec(2) pdec(3)

logit missing_abs Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir if col25=="GUI"
outreg2 using missing.tex, tex(fragment pretty) append	dec(2) pdec(3)

logit missing_abs Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir if col25=="SOU"
outreg2 using missing.tex, tex(fragment pretty) append	dec(2) pdec(3)

logit missing_abs pcpop admin_total limit Total_posts log_predist border_percent ind_fleuve coltotal log_distance wwi_resist log_area anc_comptoir year if col25=="NIG"
outreg2 using missing.tex, tex(fragment pretty) append	dec(2) pdec(3)

logit missing_abs Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir year if col25=="SEN"
outreg2 using missing.tex, tex(fragment pretty) append	dec(2) pdec(3)

drop missing_abs

*Table 6: Main Paper Expanded Results Table 

reg abs_pop Rails_per50k i.ccode i.year
outreg2 using ols.tex, tex(fragment pretty) replace	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg abs_pop Rails_per50k pcpop wwi_resist anc_comptoir altitude border_percent log_predist log_distance  log_area  i.ccode i.year
outreg2 using ols.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg abs_pop Rails_per50k placebo2 pcpop altitude log_predist log_distance border_percent wwi_resist log_area anc_comptoir i.ccode i.year
outreg2 using ols.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total border_percent limit altitude log_predist log_distance wwi_resist log_area anc_comptoir i.ccode i.year
outreg2 using ols.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir i.ccode i.year
outreg2 using ols.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)


*Table 7: Railways and Draft Evasion - Random Effects, OLS, Year Fixed Effects

xtset cercleid year

xtreg abs_pop Rails_per50k i.year, re cluster(cercleid)
outreg2 using re.tex, tex(fragment pretty) replace	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop Rails_per50k pcpop wwi_resist anc_comptoir altitude border_percent log_predist log_distance  log_area i.year, re cluster(cercleid)
outreg2 using re.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop Rails_per50k placebo2 pcpop altitude log_predist log_distance border_percent wwi_resist log_area anc_comptoir i.year, re cluster(cercleid)
outreg2 using re.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total border_percent limit altitude log_predist log_distance wwi_resist log_area anc_comptoir i.year, re cluster(cercleid)
outreg2 using re.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir i.year, re cluster(cercleid)
outreg2 using re.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)


*Table 8: Railways and Draft Evasion - Random Effects, OLS, No Year Fixed Effects

xtset cercleid year

xtreg abs_pop Rails_per50k, re cluster(cercleid)
outreg2 using re2.tex, tex(fragment pretty) replace	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop Rails_per50k pcpop wwi_resist anc_comptoir altitude border_percent log_predist log_distance  log_area, re cluster(cercleid)
outreg2 using re2.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop Rails_per50k placebo2 pcpop altitude log_predist log_distance border_percent wwi_resist log_area anc_comptoir, re cluster(cercleid)
outreg2 using re2.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total border_percent limit altitude log_predist log_distance wwi_resist log_area anc_comptoir, re cluster(cercleid)
outreg2 using re2.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir, re cluster(cercleid)
outreg2 using re2.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)


*Table 9: Lagged Dependent Variable

xtset cercleid year

xtreg abs_pop l.abs_pop Rails_per50k, re cluster(cercleid)
outreg2 using lag.tex, tex(fragment pretty) replace	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(l.abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop l.abs_pop Rails_per50k pcpop wwi_resist anc_comptoir altitude border_percent log_predist log_distance  log_area, re cluster(cercleid)
outreg2 using lag.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(l.abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop l.abs_pop Rails_per50k placebo2 pcpop altitude log_predist log_distance border_percent wwi_resist log_area anc_comptoir, re cluster(cercleid)
outreg2 using lag.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(l.abs_pop  Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop l.abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total border_percent limit altitude log_predist log_distance wwi_resist log_area anc_comptoir, re cluster(cercleid)
outreg2 using lag.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(l.abs_pop  Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

xtreg abs_pop l.abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir, re cluster(cercleid)
outreg2 using lag.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(l.abs_pop  Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)


*Table 10: Descriptive Statistics (Subsample v. Senegal v. Full Sample)
****note: to preserve space, remove columns of ttest p-values in final version

gen canton_sample = 0
replace canton_sample = 2 if col25=="SEN"
replace canton_sample = 1 if cercle=="Sinesaloum" || cercle=="Thies" || cercle=="Louga" || cercle=="Casamance" || cercle=="Tivaouane" || cercle=="Tambacounda" || cercle=="Dagana" || cercle=="Bakel" || cercle=="Matam"


eststo canton: estpost summarize $VARS if canton_sample==1
eststo sen: estpost summarize $VARS if canton_sample==2
eststo aof: estpost summarize $VARS if canton_sample==0
eststo csen: estpost ttest $VARS if col25=="SEN", by(canton_sample)
eststo caof: estpost ttest $VARS if canton_sample <=1, by(canton_sample)

esttab canton canton canton canton sen sen sen sen aof aof aof aof csen caof using eI_des.tex, replace ///
cell(mean(pattern(1 0 0 0 1 0 0 0 1 0 0 0 0 0) fmt(2)) & sd(pattern(0 1 0 0 0 1 0 0 0 1 0 0 0 0) fmt(2)) & min(pattern(0 0 1 0 0 0 1 0 0 0 1 0 0 0) fmt(2)) & max(pattern(0 0 0 1 0 0 0 1 0 0 0 1 0 0) fmt(2)) & p(pattern(0 0 0 0 0 0 0 0 0 0 0 0 1 1) fmt(2))) mtitle(Mean" "SD" "Min" "Max" Mean" "SD" "Min" "Max" "Mean" "SD" "Min" "Max" "p-value" "p-value")

drop canton_sample


*Table 18: Explaining Error Correction in Census - OLS

reg any_error Rails_per50k i.ccode i.year
outreg2 using error.tex, tex(fragment pretty) replace	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg any_error Rails_per50k pcpop wwi_resist anc_comptoir altitude border_percent log_predist log_distance  log_area  i.ccode i.year
outreg2 using error.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg any_error Rails_per50k placebo2 pcpop altitude log_predist log_distance border_percent wwi_resist log_area anc_comptoir i.ccode i.year
outreg2 using error.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg any_error Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total border_percent limit altitude log_predist log_distance wwi_resist log_area anc_comptoir i.ccode i.year
outreg2 using error.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg any_error Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir i.ccode i.year
outreg2 using error.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)
xtset cercleid year


*Table 19: Legal Exemptions to the Draft - OLS

reg ex_pop Rails_per50k i.ccode i.year
outreg2 using ex.tex, tex(fragment pretty) replace	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg ex_pop Rails_per50k pcpop wwi_resist anc_comptoir altitude border_percent log_predist log_distance  log_area  i.ccode i.year
outreg2 using ex.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg ex_pop Rails_per50k placebo2 pcpop altitude log_predist log_distance border_percent wwi_resist log_area anc_comptoir i.ccode i.year
outreg2 using ex.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg ex_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total border_percent limit altitude log_predist log_distance wwi_resist log_area anc_comptoir i.ccode i.year
outreg2 using ex.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)

reg ex_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir i.ccode i.year
outreg2 using ex.tex, tex(fragment pretty) append	dec(2) pdec(3) alpha(0.001, 0.01, 0.05) keep(Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations coltotal log_distance wwi_resist log_area anc_comptoir)
xtset cercleid year


*Figures************************************************************************

*Figures 2: Two Way Fixed Effects (w/wo Controls)
xtreg abs_pop railway i.year, fe
estimates store A
xtreg abs_pop avg_rail_bb i.year, fe
estimates store B
xtreg abs_pop railway border_percent limit admin_total log_distance i.year, fe
estimates store C
xtreg abs_pop avg_rail_bb border_percent limit admin_total log_distance i.year, fe
estimates store D

coefplot A B, bylabel(No Controls) || C D, bylabel(Added Controls) keep(railway avg_rail_bb border_percent limit admin_total log_distance) xline(0) scheme(s1mono)

	*note: labeled "limit" as Depression because limits were only placed during the Depression


*Figure 3: Staggered Difference in Difference - Binary - Rail/No Rail


egen mean_t = mean(railway), by(cercleid) 
gen always_t = 0
replace always_t = 1 if mean_t ==1

quietly: csdid abs_pop, ivar(id) time(year) gvar(year_train)
estat pretrend
estat simple
estat group
csdid_plot , scheme(s1mono) title("Never Treated") saving(bin1)


quietly: csdid abs_pop, ivar(id) time(year) gvar(year_train) notyet
estat pretrend
estat simple
estat group
csdid_plot, scheme(s1mono) title("Not Yet Treated") saving(bin2)

graph combine bin1.gph bin2.gph, ycommon ysize(4) xsize(9) scheme(s1mono)

*Figure 4: Staggered DnD -  Main Controls - Rail/No Rail


csdid abs_pop border_percent limit, ivar(id) time(year) gvar(year_train)
estat pretrend
estat simple
estat group
csdid_plot, scheme(s1mono) title("Never Treated") saving(cv1)

csdid abs_pop border_percent limit, ivar(id) time(year) gvar(year_train) notyet
estat pretrend
estat simple
estat group
csdid_plot, scheme(s1mono) title("Not Yet Treated") saving(cv2)

graph combine cv1.gph cv2.gph, ysize(4) xsize(9) scheme(s1mono)

*Figure 5: Staggered DnD - Added Controls - Rail/No Rail

csdid abs_pop frontmaritime limit corvee_bin border_percent, ivar(id) time(year) gvar(year_train)
estat pretrend
estat simple
estat group
csdid_plot, scheme(s1mono) title("Never Treated") saving(cov3)


csdid abs_pop frontmaritime limit corvee_bin border_percent, ivar(id) time(year) gvar(year_train) notyet
estat pretrend
estat simple
estat group
csdid_plot, scheme(s1mono) title("Not Yet Treated") saving(cov4)


graph combine cov3.gph cov4.gph, ysize(4) xsize(9) scheme(s1mono)

*Figure 6: SDnD +/-Railway - No Controls

drop mean_t
drop always_t

egen mean_t = mean(avg_rail_bb), by(cercleid)
gen always_t = 0
replace always_t = 1 if mean_t ==1

csdid abs_pop, ivar(id) time(year) gvar(avg_rail_year)
estat pretrend
estat simple
estat group
csdid_plot, scheme(s1mono) title("Never Treated") saving(bin3)


csdid abs_pop, ivar(id) time(year) gvar(avg_rail_year) notyet
estat simple
estat group
csdid_plot, scheme(s1mono) title("Not Yet Treated") saving(bin4)


graph combine bin3.gph bin4.gph, ysize(4) xsize(9) scheme(s1mono)

*Figure 7: SDnD +/- Main Controls

csdid abs_pop border_percent limit, ivar(id) time(year) gvar(avg_rail_year)
estat pretrend
estat simple
estat group
csdid_plot, scheme(s1mono) title("Never Treated") saving(cov10)

csdid abs_pop border_percent limit, ivar(id) time(year) gvar(avg_rail_year) notyet
estat pretrend
estat simple
estat group
csdid_plot, scheme(s1mono) title("Not Yet Treated") saving(cov11)

graph combine cov10.gph cov11.gph, ysize(4) xsize(9) scheme(s1mono)

*Figure 8: SDnD +/- Added Controls

csdid abs_pop frontmaritime border_percent corvee limit, ivar(id) time(year) gvar(avg_rail_year) 
estat pretrend
estat simple
estat group
csdid_plot, scheme(s1mono) title("Never Treated") saving(add1)


csdid abs_pop frontmaritime border_percent corvee limit, ivar(id) time(year) gvar(avg_rail_year) notyet
estat pretrend
estat simple
estat group
csdid_plot, scheme(s1mono) title("Not Yet Treated") saving(add2)

graph combine add1.gph add2.gph, ysize(4) xsize(9) scheme(s1mono)

*Figure 9: Conditional DiD with Never Treated as Comparison Group (Rail/No rail) - Event
drop mean_t
drop always_t

egen mean_t = mean(railway), by(cercleid)
gen always_t = 0
replace always_t = 1 if mean_t ==1


csdid abs_pop border_percent frontmaritime, ivar(id) time(year) gvar(year_train)
estat event
csdid_plot, scheme(s1mono) xline(0) 

*Figure 10:  Conditional DiD with Never Treated as Comparison Group (Rail/No rail) - Groups
csdid abs_pop border_percent limit, ivar(id) time(year) gvar(year_train)
csdid_estat attgt

csdid_plot, group(1924) scheme(s1mono) title(Group 1924) saving(a)
csdid_plot, group(1928) scheme(s1mono) title(Group 1928) saving(b)
csdid_plot, group(1931) scheme(s1mono) title(Group 1931) saving(c)
csdid_plot, group(1932) scheme(s1mono) title(Group 1932) saving(d)
csdid_plot, group(1936) scheme(s1mono) title(Group 1936) saving(e)

graph combine a.gph b.gph c.gph d.gph e.gph, ysize(9) xsize(14) scheme(s1mono)

*Figure 11: Conditional DiD with Never Treated as Comparison Group (+/- Railway) - Groups
drop mean_t
drop always_t

egen mean_t = mean(avg_rail_bb), by(cercleid)
gen always_t = 0
replace always_t = 1 if mean_t ==1


csdid abs_pop border_percent limit, ivar(id) time(year) gvar(avg_rail_year)
estat simple
csdid_estat attgt
csdid_plot, group(1924) scheme(s1mono) title(Group 1924) saving(f)
csdid_plot, group(1929) scheme(s1mono) title(Group 1928) saving(g)
csdid_plot, group(1931) scheme(s1mono) title(Group 1931) saving(h)
csdid_plot, group(1933) scheme(s1mono) title(Group 1932) saving(i)

graph combine f.gph g.gph h.gph i.gph, ysize(8) xsize(14) scheme(s1mono)

*Figure 12: Avg. Reserves with Language and Job Skills
graph bar useful_reserve read_reserve speak_reserve, over(railway) over(col25) stack scheme(s1mono) bar(1, color(erose)) bar(2, color(purple)) bar(3, color(lavender))

*Figure 13: Avg Conscripts with Language and Job Skills

graph bar useful_conscripts read_conscripts speak_conscripts, over(railway) over(col25) stack scheme(s1mono) bar(1, color(cyan)) bar(2, color(gold)) bar(3, color(navy))


*Figure 14: TWFE on Population Density within Cercles
xtset cercleid year
xtreg pop_density railway  border_percent log_distance i.year, fe
estimates store Binary
xtreg pop_density Rails_per50k border_percent log_distance i.year, fe
estimates store Density

coefplot Binary Density, keep(railway Rails_per50k border_percent log_distance) xline(0) scheme(s1mono)

*Figure 16: Months When Conscription Took Place
graph bar (count) if col25=="SEN" || col25=="SOU", over(month_num) saving(ss) scheme(s1mono) ytitle(Count) title("Senegal, Soudan")

graph bar (count) if col25=="GUI" || col25=="HV" || col25=="DAH" || col25=="CDI", over(month_num) saving(chdg) scheme(s1mono) ytitle("") title("CDI, HV, DAH, GUI")

graph combine ss.gph chdg.gph, ycommon


*Figure 16: Variation in Error Correction Across Colonies

xtreg any_error Rails_per50k border_percent pop_density admin_total i.year, fe

coefplot, keep(Rails_per50k border_percent pop_density admin_total) xline(0) scheme(s1mono)


*Figure 13: Names Added and Removed Across Colonies

xtreg added Rails_per50k border_percent pop_density admin_total i.year, fe
estimates store Added

xtreg removed Rails_per50k border_percent pop_density admin_total i.year, fe
estimates store Removed

coefplot Added || Removed,  keep(Rails_per50k border_percent pop_density admin_total) xline(0) scheme(s1mono)


*Figure 14: Legal Exemptions to the Draft

graph bar ex_pop, over(railway) over(col25) scheme(s1mono) ytitle(Average % Exemptions)

********************************************************************************
*Additional Statistics, Checks and Analysis in Appendix*************************

*C.I.i. Hausman and Breusch-Pagan Lagrange Multiplier Tests
xtset cercleid year 
xtreg  abs_pop l.abs_pop, fe
estimates store fixed
xtreg abs_pop l.abs_pop, re
estimates store random
hausman fixed random /*rejects null*/

xtreg  abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude border_percent log_predist ind_fleuve precipitations admin_total coltotal log_distance wwi_resist log_area anc_comptoir, fe
estimates store fixed
xtreg abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude border_percent ind_fleuve log_predist precipitations admin_total coltotal log_distance wwi_resist log_area anc_comptoir, re
estimates store random
hausman fixed random /*does not reject null*/

xtset cercleid year 
xtreg  abs_pop l.abs_pop i.ccode
estimates store fixed
xtreg abs_pop l.abs_pop, re
estimates store random
hausman fixed random /*rejects null*/

xtreg  abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude  border_percent log_predist ind_fleuve precipitations admin_total coltotal log_distance wwi_resist log_area anc_comptoir i.ccode
estimates store fixed

xtreg abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude log_predist border_percent ind_fleuve precipitations admin_total coltotal log_distance wwi_resist log_area anc_comptoir, re
estimates store random
hausman fixed random /*does not reject null*/

xtreg abs_pop Rails_per50k placebo2 building_rail corvee_bin pcpop admin_total limit Total_posts altitude border_percent log_predist ind_fleuve precipitations admin_total coltotal log_distance wwi_resist log_area anc_comptoir, re
xttest0 /*random effects appropriate*/

*F.II.ii.: Two Tailed T-Test on Eligible Population
ttest eligible, by(railway)
ttest pop_density, by(railway)

